
$(function(){
  var styleList = ['left', 'top', 'bottom', 'right', 'width', 'height', 'fontSize', 'lineHeight']
  var hStyle = /left|right|width|fontSize/
  var vStyle = /top|bottom|height|lineHeight/
  var pinfoRefresh = _.debounce(function (){
    var elScale = {
      x: window.innerWidth/PINFO.width,
      y: window.innerHeight/PINFO.height
    }
    $('.'+PINFO.className).each(function(){
      var el = this
      var $this = $(this)

      var styles = $this.data('styles')
      if(!styles){
        styles = {}
        _.each(styleList, function(item){
          if(el.style[item]){
            styles[item] = parseFloat(el.style[item])
          }
        })
        $this.data('styles', styles)
      }
      _.each(_.keys(styles), function(item){
        var value = styles[item]
        if(hStyle.test(item)){
          value*=elScale.x
        }
        if(vStyle.test(item)){
          value*=elScale.y
        }
        $this.css(item, value)
      })
    })
  }, 200)
  $(window).on('resize', pinfoRefresh)
  pinfoRefresh()
})